//
// Button groups
// --------------------------------------------------

// Make the div behave like a button
.@{ns}btn-group,
.@{ns}btn-group-vertical {
  position: relative;
  display: inline-block;
  vertical-align: middle; // match .btn alignment given font-size hack above

  > .@{ns}btn {
    position: relative;
    float: left;

    // Bring the "active" ghost-button to the front.
    &.@{ns}btn-ghost:hover,
    &.@{ns}btn-ghost:focus,
    &.@{ns}btn-ghost:active {
      z-index: 2;
    }
  }
}

.@{ns}btn-group {
  //** Buttons in the button group have no border radius
  :not(:first-child):not(:last-child),
  > .@{ns}dropdown:not(:first-child):not(:last-child) > .@{ns}dropdown-toggle > .@{ns}btn {
    border-radius: 0;
  }

  //** Horizontal Button remove border radius
  &:not(.@{ns}btn-group-vertical) > .@{ns}btn:first-child,
  &:not(.@{ns}btn-group-vertical) > .@{ns}dropdown:first-child > .@{ns}dropdown-toggle > .@{ns}btn {
    .border-right-radius(0);
  }

  &:not(.@{ns}btn-group-vertical) > .@{ns}btn:last-child,
  &:not(.@{ns}btn-group-vertical) > .@{ns}dropdown:last-child > .@{ns}dropdown-toggle > .@{ns}btn {
    .border-left-radius(0);
  }

  //** Vertical Button remove radius
  &.@{ns}btn-group-vertical > .@{ns}btn:first-child,
  &.@{ns}btn-group-vertical > .@{ns}dropdown:first-child > .@{ns}dropdown-toggle > .@{ns}btn {
    .border-bottom-radius(0);
  }

  &.@{ns}btn-group-vertical > .@{ns}btn:last-child,
  &.@{ns}btn-group-vertical > .@{ns}dropdown:last-child > .@{ns}dropdown-toggle > .@{ns}btn {
    .border-top-radius(0);
  }

  &.@{ns}btn-group-vertical > .@{ns}dropdown,
  &.@{ns}btn-group-vertical > .@{ns}dropdown-dropup {
    display: block;
  }

  .@{ns}btn + .@{ns}btn,
  .@{ns}btn + .@{ns}btn-group,
  .@{ns}btn-group + .@{ns}btn,
  .@{ns}btn-group + .@{ns}btn-group {
    margin-left: -1px;
  }
}

// Optional: Group multiple button groups together for a toolbar
.@{ns}btn-toolbar {
  &:extend(.clearfix all);

  .@{ns}btn,
  .@{ns}btn-group,
  .@{ns}input-group,
  .@{ns}dropdown {
    float: left;
  }

  > :not(:first-child):not(.@{ns}btn-block) {
    margin-left: 5px;
  }
}

// Custom edits for including btn-groups within btn-groups (useful for including dropdown buttons within a btn-group)
.@{ns}btn-group > .@{ns}btn-group {
  float: left;
}

.@{ns}btn-group > .@{ns}btn-group:not(:first-child):not(:last-child) > .@{ns}btn {
  border-radius: 0;
}

.@{ns}btn-group > .@{ns}btn-group:first-child:not(:last-child) {
  > .@{ns}btn:last-child,
  > .@{ns}dropdown-toggle {
    .border-right-radius(0);
  }
}

.@{ns}btn-group > .@{ns}btn-group:last-child:not(:first-child) > .@{ns}btn:first-child {
  .border-left-radius(0);
}

// On active and open, don't show outline
.@{ns}btn-group .dropdown-toggle:active,
.@{ns}btn-group.open .dropdown-toggle {
  outline: 0;
}

// Sizing
//
// Remix the default button sizing classes into new ones for easier manipulation.

.@{ns}btn-group-xs > .@{ns}btn {
  &:extend(.btn-xs);
}

.@{ns}btn-group-sm > .@{ns}btn {
  &:extend(.btn-sm);
}

.@{ns}btn-group-lg > .@{ns}btn {
  &:extend(.btn-lg);
}

// Split button dropdowns
// ----------------------
.@{ns}btn-group.@{ns}open {
  .@{ns}dropdown-toggle.@{ns}btn {
    z-index: (@zindex-dropdown+10);

    &,
    &:active,
    &:focus,
    &:hover {
      background: white;
      padding-bottom: (@padding-base-vertical+1);
    }

    &:hover {
      padding-bottom: (@padding-base-vertical+1);
    }

    &.@{ns}btn-lg {
      &,
      &:active,
      &:focus,
      &:hover {
        padding-bottom: (@padding-large-vertical+1);
      }
    }

    &.@{ns}btn-sm {
      &,
      &:active,
      &:focus,
      &:hover {
        padding-bottom: (@padding-small-vertical+1);
      }
    }

    &.@{ns}btn-xs {
      &,
      &:active,
      &:focus,
      &:hover {
        padding-bottom: (@padding-extra-small-vertical+1);
      }
    }
  }

  .@{ns}dropdown-menu {
    z-index: (@zindex-dropdown+5);
  }
}

.@{ns}btn-group.@{ns}open.@{ns}dropup {
  .@{ns}dropdown-toggle.@{ns}btn {
    z-index: (@zindex-dropdown+10);

    &,
    &:active,
    &:focus,
    &:hover {
      background: white;
      padding-top: (@padding-base-vertical+1);
      padding-bottom: @padding-base-vertical;
    }

    &:hover {
      padding-top: (@padding-base-vertical+1);
      padding-bottom: @padding-base-vertical;
    }

    &.btn-lg {
      &,
      &:active,
      &:focus,
      &:hover {
        padding-top: (@padding-large-vertical+1);
        padding-bottom: @padding-large-vertical;
      }
    }

    &.@{ns}btn-sm {
      &,
      &:active,
      &:focus,
      &:hover {
        padding-top: (@padding-small-vertical+1);
        padding-bottom: @padding-small-vertical;
      }
    }

    &.@{ns}btn-xs {
      &,
      &:active,
      &:focus,
      &:hover {
        padding-top: (@padding-extra-small-vertical+1);
        padding-bottom: @padding-extra-small-vertical;
      }
    }
  }
}

// Give the line between buttons some depth
.@{ns}btn-group > .@{ns}btn + .@{ns}dropdown-toggle {
  padding-left: 8px;
  padding-right: 8px;
}

.@{ns}btn-group > .@{ns}btn-lg + .@{ns}dropdown-toggle {
  padding-left: 12px;
  padding-right: 12px;
}

// The clickable button for toggling the menu
// Remove the gradient and set the same inset shadow as the :active state
.@{ns}btn-group.open .@{ns}dropdown-toggle {
  box-shadow: none;

  // Show no shadow for `.btn-link` since it has no other button styles.
  &.btn-link {
    box-shadow: none;
  }
}

// Reposition the caret
.@{ns}btn .@{ns}caret {
  margin-left: 0;
}

// Vertical button groups
// ----------------------

.@{ns}btn-group-vertical {
  > .@{ns}btn,
  > .@{ns}btn-group,
  > .@{ns}btn-group > .@{ns}btn {
    display: block;
    float: none;
    width: 100%;
    max-width: 100%;
  }

  // Clear floats so dropdown menus can be properly placed
  > .@{ns}btn-group {
    &:extend(.clearfix all);

    > .@{ns}btn {
      float: none;
    }
  }

  > .@{ns}btn + .@{ns}btn,
  > .@{ns}btn + .@{ns}btn-group,
  > .@{ns}btn-group + .@{ns}btn,
  > .@{ns}btn-group + .@{ns}btn-group {
    margin-top: -1px;
    margin-left: 0;
  }
}

// Justified button groups
// ----------------------

.@{ns}btn-group-justified {
  display: table;
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;

  > .@{ns}btn,
  > .@{ns}btn-group {
    float: none;
    display: table-cell;
    width: 1%;
  }

  > .@{ns}btn-group .@{ns}btn {
    width: 100%;
  }

  > .@{ns}btn-group .@{ns}dropdown-menu {
    left: auto;
  }

  > .@{ns}btn-ghost {
    border-left-width: 0;
    border-right-width: 0;
    position: relative;

    .btn-ghost-hack-variant(@btn-ghost-border-color);

    &::before,
    &::after {
      content: "";
      display: block;
      position: absolute;
      width: @btn-ghost-border-width;
      background-color: @btn-ghost-border-color;
      top: -1 * @btn-ghost-border-width;
      bottom: -1 * @btn-ghost-border-width;
      .btn-transition(color-and-border);
    }

    &::before {
      left: 0;
    }

    &::after {
      right: -1px;
    }
  }

  > .@{ns}btn-ghost:first-child {
    border-left-width: @btn-ghost-border-width;

    &::before {
      display: none;
    }
  }

  > .@{ns}btn-ghost:last-child {
    border-right-width: @btn-ghost-border-width;

    &::after {
      display: none;
    }
  }
}

//suite-button-group
//------------------
.@{ns}btn-group-primary {
  .button-group-btn(@H500, @H050);
}

.@{ns}btn-group-link {
  .button-group-btn(@H500, @H050);

  // Rewrite disabled styles
  &.@{ns}btn-group {
    .@{ns}btn.disabled:hover {
      background-color: white;
      color: @H050;
    }

    .@{ns}btn-link:focus,
    .@{ns}btn-link:hover {
      color: white;
    }
  }
}

// Reset button size in button group.
.@{ns}btn-group-lg {
  .@{ns}btn {
    .btn-lg;
  }
}

.@{ns}btn-group-sm {
  .@{ns}btn {
    .btn-sm;
  }
}

.@{ns}btn-group-xs {
  .@{ns}btn {
    .btn-xs;
  }
}
